/*
 *email: chen983@sina.com
 *
 */
#ifndef _ORACLE_READER_H__
#define _ORACLE_READER_H__
#include <string>
#include <vector>
using namespace std;
#include "row.h"

namespace Oracle
{

class Command;

#define max_select_items 255
#define max_vname_len2 32

class Reader
{
protected:
	Reader(void *ctx, Command &command);
	virtual ~Reader();
	
public:
	virtual void open()=0;
	virtual void close(bool deleteThis=true)=0;
	virtual bool read()=0;
	virtual void bindParameter(const char *value)=0;
	virtual void bindOutputParameter(string &value)=0;
	
	const char *getData(int col)
	{
		return _row.field(col).data;
	}
	const string & getName(int col)
	{
		return _row.field(col).name;
	}
	int getType(int col)
	{
		return _row.field(col).type;
	}
	int fieldCount()
	{
		return _row.fieldCount();
	}
	int getLength(int col)
	{
		return _row.field(col).max_len;
	}
	int isNull(int col)
	{
		return _row.field(col).null;
	}
	
protected:
	void rtrim(char *str);
	
protected:
	
	Row _row;

	void *_ctx;
	Command &_command;
	
	const char *_commandText;
	bool _open;
};

};
#endif
